//
//  WalletObj.m
//  FbeeAPP
//
//  Created by dev-m on 2018/3/20.
//  Copyright © 2018年 mohao. All rights reserved.
//

#import "WalletObj.h"

@implementation WalletObj

-(void)setDataByDict:(NSDictionary *)dict
{
    self.address = SafeGetStringValue([dict objectForKey:@"address"]);
    self.name = SafeGetStringValue([dict objectForKey:@"name"]);
    self.symbol = SafeGetStringValue([dict objectForKey:@"symbol"]);
    self.lastUpdated = SafeGetStringValue([dict objectForKey:@"lastUpdated"]);
    self.balance = SafeGetStringValue([dict objectForKey:@"balance"]);
    
    NSString *decimals = SafeGetStringValue([dict objectForKey:@"decimals"]);
    if (![NSString isEmptyString:decimals]) {
        NSDecimalNumber *oban = [[NSDecimalNumber alloc] initWithString:self.balance];
        NSDecimalNumber *bb = [[NSDecimalNumber alloc] initWithString:[NSString stringWithFormat:@"1e+%@",decimals]];
        self.balance = [NSString stringWithFormat:@"%@",[oban decimalNumberByDividingBy:bb]];
    }
    
}

-(NSDictionary *)getDictbyData
{
    return @{@"address":SafeString(self.address),@"name":SafeString(self.name),
             @"symbol":SafeString(self.symbol),@"lastUpdated":SafeString(self.lastUpdated),
             @"balance":SafeString(self.balance)};
}

@end
